package main

import (
	"fmt"
	"sync"
)

func Iter(set *sync.Map) <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		set.Range(func(k, v interface{}) bool {
			fmt.Println("key is ", k)
			fmt.Println("value is ", v)
			ch <- v
			return true
		})
		close(ch)
	}()
	return ch
}

func main() {
	safe_map := sync.Map{}
	safe_map.Store("zack", 1024)
	safe_map.Store("bob", 2048)
	safe_map.Store("vivo", 9096)
	ch := Iter(&safe_map)
	<-ch
}
